package com.jiang.专题.哈希表.Q383;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/01/23 19:06
 */
class Solution {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] arr = new int[26];
        for (int i = 0; i < magazine.length(); i++) {
            arr[magazine.charAt(i) - 'a']++;
        }
        for (int i = 0; i < ransomNote.length(); i++) {
            int c= ransomNote.charAt(i) - 'a';
            if (arr[c] == 0) return false;
            arr[c]--;
        }
        return true;
    }
}